package com.jason.test;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.fclassroom.logger.entity.SystemLog;
import com.jason.framework.exception.BaseException;
import com.jason.framework.util.JsonUtil;

public class KafkaLogTester {

	protected static final Logger logger = LogManager.getLogger(KafkaLogTester.class);

	public static void main(String[] args) {
		String[] str = new String[] {};
		for (int i = 1; i <= 3; i++) {
			try {
				System.out.println(str[2]);
			} catch (Exception e) {
				logger.error(e);
			}
			logger.info("HI this is a test for:" + i + " It works! ");
		}
		// tailLog();
	}

	public static void tailLog() {
		try {
			BufferedReader br = new BufferedReader(new FileReader(
					"/Users/jason/Documents/workspace_jike/EduDiagnosis-java/Fclassroom-service-logger/${catalina.home}/logs/fzclassroom/info.log"));
			String line;
			while ((line = br.readLine()) != null) {
				SystemLog systemLog;
				try {
					systemLog = new SystemLog(line);
					logger.info(JsonUtil.toJson(systemLog));
				} catch (BaseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
